package com.shujia.wyh.day15;

/*
        模拟登录,给三次机会,并提示还有几次。
 */

import java.util.Scanner;
public class StringTest1 {
    public static void main(String[] args) {
        String username = "xiaohu";
        String password = "123456";

        //创建键盘录入对象
        Scanner sc = new Scanner(System.in);
        int count = 3;
        while (count>0){
            count--;
            System.out.println("请输入用户名：");
            String username2 = sc.next();
            System.out.println("请输入密码：");
            String password2 = sc.next();
            if(username.equals(username2) && password.equals(password2) ){
                System.out.println("登录成功！！！");
                System.out.println("正在跳入主界面。。。。");
                break;
            }else {
                System.out.println("您输入的用户名和密码错误，请重新输入，您还有"+count+"次机会！");
            }
        }


    }
}
